package com.cxj.controller;

import com.cxj.service.AdminService;
import com.cxj.service.YmService;
import com.cxj.vo.SelectByYmNameRes;
import com.cxj.vo.User;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Administrator")
public class AdministratorController {
    @Resource
    private YmService ymService;
    @Resource
    private AdminService adminService;

    //插入新疫苗
    @PostMapping("/insertNewYm")
    public String insertNewYm(@RequestParam String VNAME, @RequestParam String VIntroduction) {
        String res = ymService.insertNewYm(VNAME, VIntroduction);
        return res;
    }

    //删除疫苗
    @PostMapping("/deleteYm")
    public String DeleteYm(@RequestParam String VName) {
        Boolean res = ymService.deleteYm(VName);
        if (res) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }

    //修改疫苗信息
    @PostMapping("/updateYm")
    public String UpdateYm(@RequestParam String VNAME, @RequestParam String VIntroduction) {
        String res = ymService.UpdateYm(VNAME, VIntroduction);
        return res;
    }

    //依据名称查询疫苗
    @PostMapping("/selectYmByName")
    public SelectByYmNameRes selectByYmNameRes(@RequestParam String ymName) {
        SelectByYmNameRes selectByYmNameRes = ymService.selectByYmName(ymName);
        return selectByYmNameRes;
    }

    //依据名字查询用户信息
    @PostMapping("/selectUserByName")
    public User SelectUserByUserName(@RequestParam String Name) {
        User userInfo = adminService.SelectUserByUserName(Name);
        return userInfo;
    }
}
